package edu.kit.aifb.ldstream.stat.distrib;

import java.io.Serializable;

public class NormalDistribution implements IDistribution, Serializable {
	

	private static final long serialVersionUID = -2871497863345670754L;

	private double mean;
	private double sd;
	
	public NormalDistribution(double mean, double sd){
		this.mean = mean;
		this.sd = sd;
	}
		
	/**
	 * @return the mean
	 */
	public double getMean() {
		return mean;
	}

	/**
	 * @return the sd
	 */
	public double getSd() {
		return sd;
	}

	@Override
	public int getDistributionType() {
		return IDistribution.NORMAL;
	}

	public String toString(){
		StringBuilder sb = new StringBuilder(" NormalDistribution with ");
		sb.append(" mean: ");
		sb.append(this.mean);
		sb.append(" sd: ");
		sb.append(this.sd);
		return sb.toString();
	}
	
	public boolean equals(Object o){
		if(o instanceof NormalDistribution){
			NormalDistribution nd = (NormalDistribution) o;
			return (Math.abs(this.mean - nd.mean) < 0.01d) && (Math.abs(this.sd - nd.sd) < 0.01d);
		}
		return false;
	}
	
	public int hashCode(){
		return (int)(this.mean * 10000) + (int)(this.sd * 10000);
	}
}
